import React from 'react';

/**
 * Icon 类
 *
 * @export
 * @class Icon
 * @extends {React.PureComponent<Props>}
 */
export class Icon extends React.PureComponent {
    static defaultProps = {
        size: 20,
        color: '#333333',
        className: null,
        style: {},
    };

    // 高宽比 height / width
    ratio = 1;

    getSize = () => {
        const { size } = this.props;

        const [, value = 20, unit = ''] = (size || '').toString().match(/^(\d+(?:\.\d+)?)\s?(.*)$/) || [];

        return {
            width: `${value}${unit}`,
            height: `${value * this.ratio}${unit}`,
        };
    };
}
